use clap::{command, Parser};

mod myagent;
mod rpc_server;

/// Command-line arguments
#[derive(Parser, Debug)]
#[command(
    name = "configmonitor_agent",
    version = "1.0",
    author = "Zhenxiong Tian",
    about = "Agent for monitoring configuration files"
)]
struct Args {
    /// configmonitor_server的rpc地址
    #[arg(short, long)]
    server_addr: String,
    /// 本节点的rpc server地址
    #[arg(short, long)]
    addr: String,
}

// https://docs.rs/tokio/latest/tokio/attr.main.html#set-number-of-worker-threads
// 单进程理由：agent的功能比较简单；audit规则需要pid过滤。
#[tokio::main(worker_threads = 1)]
async fn main() {
    let args = Args::parse();
    myagent::MyAgent::new(args.server_addr, args.addr)
        .run()
        .await
        .unwrap();
}
